//
//  SSSRecordOrderToEditingCell.m
//  SSSMerchant
//
//  Created by 谢曦 on 2017/3/22.
//  Copyright © 2017年 xnxin. All rights reserved.
//

#import "SSSRecordOrderToEditingCell.h"
@interface SSSRecordOrderToEditingCell()
@property (nonatomic,weak) UIImageView *typeImageView;
@property (nonatomic,weak) UILabel *phoneLable;
@property (nonatomic,weak) UILabel *titleLable;
@property (nonatomic,weak) UILabel *moneyLable;
@property (nonatomic,weak) UIImageView *arrowImage;
@property (nonatomic,weak) UILabel *timeLable;
@property (nonatomic,weak) UILabel *dateLable;
@end
@implementation SSSRecordOrderToEditingCell
+(instancetype)cellForTableView:(UITableView *)tableView withIdentifier:(NSString *)identifier{
    SSSRecordOrderToEditingCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier ];
    if (!cell) {
        cell=[[SSSRecordOrderToEditingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.backgroundColor=[UIColor clearColor] ;;
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        [cell initialAppearance];
        
    }
    return cell;
}

-(void)initialAppearance{
    UILabel *dateLable=[UILabel new];
    dateLable.font=Font(12);
    [self addSubview:dateLable];
    dateLable.textColor=[UIColor colorWithHex:@"BBBBBB"];
    [dateLable sizeToFit];
    [dateLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(20);
        make.left.mas_equalTo(15);
    }];
    _dateLable=dateLable;
    
    
    UILabel *timeLable=[UILabel new];
    timeLable.font=Font(12);
    [self addSubview:timeLable];
    timeLable.textColor=[UIColor colorWithHex:@"BBBBBB"];
    [timeLable sizeToFit];
    [timeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dateLable.mas_bottom);
        make.right.equalTo(dateLable.mas_right);
    }];
    _timeLable=timeLable;

  
    
    
    UIImageView *typeImageView=[UIImageView new];
    [self.contentView addSubview:typeImageView];
    [typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(28, 28));
        make.left.equalTo(timeLable.mas_right).with.offset(5);
         make.top.equalTo(dateLable);
    }];
    _typeImageView=typeImageView;
    
    UIView *line1=[UIView new];
    [self.contentView addSubview:line1];
    line1.backgroundColor=ThemeGreenColor;
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(1);
        make.centerX.equalTo(typeImageView);
        make.top.mas_equalTo(self);
         make.bottom.mas_equalTo(typeImageView.mas_top);
    }];

    UIView *line2=[UIView new];
    [self.contentView addSubview:line2];
    line2.backgroundColor=ThemeGreenColor;
    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(1);
        make.centerX.equalTo(line1);
        make.top.equalTo(typeImageView.mas_bottom);
        make.bottom.equalTo(self);
    }];

    UIView *whiteView=[self whiteView];
    whiteView.layer.cornerRadius=4;
   
    [self.contentView addSubview:whiteView];
    [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dateLable);
        make.left.equalTo(typeImageView.mas_right).with.offset(15);
        make.right.mas_equalTo(-15);
          make.bottom.equalTo(self).with.offset(-5);
    }];

    
    
    
    


}
-(UIView *)whiteView{
    UIView *whiteView=[UIView new];
    whiteView.layer.cornerRadius=4;
    whiteView.backgroundColor=[UIColor whiteColor];
    [self.contentView addSubview:whiteView];

    
    UIImageView *pic=[UIImageView new];
    pic.image=[UIImage imageNamed:@"icon_phone"];
    [whiteView addSubview:pic];
    [pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(whiteView).with.offset(21);
        make.top.equalTo(whiteView).with.offset(10);
    }];
   

    
        UILabel *phoneLable=[UILabel new];
        phoneLable.font=Font(13);
        [whiteView addSubview:phoneLable];
        phoneLable.textColor=[UIColor colorWithHex:@"6D6D6D"];
        [phoneLable sizeToFit];
        [phoneLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(pic);
            make.left.equalTo(pic.mas_right).with.offset(5);
        }];
        _phoneLable=phoneLable;

    UILabel *lable=[UILabel new];
    lable.font=Font(12);
    lable.text=@"消费金额";
    [whiteView addSubview:lable];
    lable.textColor=[UIColor colorWithHex:@"6D6D6D"];
    [lable sizeToFit];
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(pic.mas_bottom).with.offset(12);
        make.left.equalTo(pic);
    }];
    
    
    UILabel *moneyLable=[UILabel new];
    moneyLable.font=Font(13);
    [whiteView addSubview:moneyLable];
    moneyLable.textColor=[UIColor colorWithHex:@"6D6D6D"];
    [moneyLable sizeToFit];
    [moneyLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lable);
        make.left.equalTo(lable.mas_right).with.offset(44);
    }];
    _moneyLable=moneyLable;

    UIImageView *arrow=[UIImageView new];
    arrow.image=[UIImage imageNamed:@"icon_arrow_right_gray"];
    [whiteView addSubview:arrow];
    [arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(whiteView).with.offset(-22);
        make.centerY.equalTo(whiteView);
    }];
    return whiteView;
    
    
    
}


-(void)setModel:(SSSRecordOrderModel *)model{
    _model=model;
    _timeLable.text=model.time;
    _dateLable.text=model.date;
    _phoneLable.text=model.phone;
    _moneyLable.text=[NSString stringWithFormat:@"¥ %@",model.money];
    _typeImageView.image=model.type==1?[UIImage imageNamed:@"icon_currentintegral"]:[UIImage imageNamed:@"icon_cumtrapz"];
    
}
@end
